##
# $Id: Makefile,v 1.1 2009-04-14 09:52:04 amaula Exp $
# \file interfaces/wrap/Makefile
# \brief Top level makefile for all wrappers
# \author Antti Maula <antti.maula@tkk.fi>
#
################################################################
#
# \note DO NOT MODIFY THIS FILE! This is a TOP-LEVEL Makefile,
# it exists only for launching subdirectory Makefiles!
#
################################################################

# GDIR define
GDIR=../../../

# MACIPATH define
MACIPATH=$(GDIR)/MaCI

# External includes
include $(GDIR)/GIMI/Makefile.gimi
include $(MACIPATH)/interfaces/MaCI-interfaces.Makefile

# params
CC=gcc
CXX=g++
EXTRADEFS=-DLINUX_OS -DGIMI_NO_DATATYPE_INCLUDES $(CE)
MACIPATH=$(GDIR)/MaCI
UTILSPATH=$(GDIR)/utils
BUSPATH=$(MACIPATH)/bus
DRIVERPATH=$(MACIPATH)/drivers
MACIINTERFACEPATH=$(MACIPATH)/interfaces
INCLUDES=-I$(UTILSPATH) $(INCGIMI) \
	-I$(BUSPATH)/ASRoboBus \
	-I$(BUSPATH)/ASRobo_serial \
	-I$(BUSPATH)/ASRobo_ioport \
	-I$(DRIVERPATH)/Ranging/SICK \
	-I$(DRIVERPATH)/Ranging/URGLaser \
	-I$(DRIVERPATH)/Motor/ESC629 \
	-I$(DRIVERPATH)/Avant/ \
	-I$(BUSPATH)/ASRobo_can/include \
	-I$(BUSPATH)/ASRobo_can \
	$(MACI_INCLUDE_PATHS)
WFLAGSC=-Wall -Wunused -Wshadow
WFLAGSCPP=-Wall -Wunused -Wshadow -Weffc++
WFLAGSDCPP=
CFLAGS=-O0 -g3 -fPIC $(WFLAGSC) $(INCLUDES) $(EXTRADEFS)
CPPFLAGS=-O0 -g3 -fPIC $(WFLAGSCPP) $(INCLUDES) $(EXTRADEFS)
DCPPFLAGS=-O0 -g3 fPIC $(WFLAGSDCPP) $(INCLUDES) $(EXTRADEFS)
LD=g++
LDFLAGS=
LIBS=$(MACI_EXT_LIBRARIES) -lrt -lpthread $(LIBSGIMI)

SRCSC=$(CGIMI)
SRCSCPP=$(CPPGIMI)
MACISRCSCPP=$(MACI_EXT_SRC_CPP) \
	    $(MACI_BASE_SRC_CPP) 
VPATH=

# Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp)
MACIOBJSCPP=$(MACISRCSCPP:.cpp=.opp)

# Define COMPILE and LINK commands
COMPILEC=$(CC) $(CFLAGS) -c
COMPILECPP=$(CXX) $(CPPFLAGS) -c
COMPILEDCPP=$(CXX) $(DCPPFLAGS) -c
LINK=$(LD) $(LDFLAGS) $(LIBS) 

# Subdirs containing modules
SUBDIRS = Python


.PHONY: all subdirs $(SUBDIRS)
all: subdirs
subdirs: $(SUBDIRS)


# Now, every subdirectory depends on the common parts, which will be compiled
# here; why? Because this is how we make this multiprocessor compatible.
$(SUBDIRS): $(OBJSC) $(OBJSCPP) $(MACIOBJSCPP)
	$(MAKE) -C $@

# Clean rules.
clean maci-clean real-clean maciclean realclean:
	for dir in $(SUBDIRS); do \
		$(MAKE) -C $$dir $@; \
	done


########### Compile rules ####################
# Compile rule for all .o (.c) file
%.o:	%.c
	@$(COMPILEC) -o $@ $<
	@echo "      [CC] $<"

# Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
	@$(COMPILECPP) -o $@ $<
	@echo "      [CXX] $<"

# Compile rule for all .dopp (dirty .cpp) files
%.dopp:	%.cpp
	@$(COMPILEDCPP) -o $@ $<
	@echo "      [DIRTY-CXX] $<"

##############################################

